<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>入库单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layui/layuiAdmin/css/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button class="layui-btn layuiadmin-btn-useradmin" data-type="dyckd">打印入库单</button>
            </div>

            <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>

            <script type="text/html" id="table-useradmin-webuser">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="roles" style="background-color: #17b3a3!important;"><i class="layui-icon layui-icon-addition"></i>分配角色</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="reset"><i class="layui-icon layui-icon-set"></i>重置密码</a>
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
            </script>
        </div>
    </div>
</div>

<script src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/jquery-3.1.1.js"></script>
<script type="text/javascript">
    layui.use(['layer','table','form'], function(){
        var $ = layui.$
            ,form = layui.form
            ,table = layui.table;
        //加载table
        table.render({
            elem: '#LAY-user-manage'
            ,url:'/dygl/queryRuKuDan'
            ,cellMinWidth: 80 //全局定义常规单元格的最小宽度
            ,title: '入库单'
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'purchase_receipt_id', title:'订单编号'}
                ,{field: 'purchase_date',title: '入库时间'}
                ,{field: 'total_price',title: '总金额'}
                ,{field: 'staff_name',title: '负责人'}
                ,{field: 'comment',title: '备注'}
            ]]
            ,page: true
        });


        //监听搜索
        form.on('submit(LAY-user-front-search)', function(data){
            var field = data.field;

            //执行重载
            table.reload('LAY-user-manage', {
                where: field
            });
        });

        //事件
        var active = {
            dyckd: function(){
                layer.open({
                    type: 2
                    ,title: '打印入库单'
                    ,content: 'userform.html'
                    ,maxmin: true
                    ,area: ['500px', '450px']
                    ,btn: ['确定', '取消']
                    ,yes: function(index, layero){
                        var iframeWindow = window['layui-layer-iframe'+ index]
                            ,submitID = 'LAY-user-front-submit'
                            ,submit = layero.find('iframe').contents().find('#'+ submitID);

                        //监听提交
                        iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                            var field = data.field; //获取提交的字段

                            //提交 Ajax 成功后，静态更新表格中的数据
                            //$.ajax({});
                            table.reload('LAY-user-front-submit'); //数据刷新
                            layer.close(index); //关闭弹层
                        });

                        submit.trigger('click');
                    }
                });
            }
        };

        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>

</body>
</html>
